The present invention relates to a method and component for tracing the operation of one or more programs.
A trace or debugging facility is often necessary when developing programs or in programs where, in the event of failure, an audit trail is required. Programmers writing in C or similar languages often use a DEBUG switch to incorporate debugging instructions when they wish to trace the operation of a program during development and to eliminate such debugging instructions in the commercially available program.
Debugging information varies from program to program according to needs and can range from simply writing xe2x80x9cI am herexe2x80x9d messages to a file, indicating a program arrived at a given point in execution, to dumping the contents of memory before halting a program, so that the state of a computer may be checked at a given point in program execution. In any case, it should be seen that debugging instructions are regarded as a processing overhead and because of this are kept to a minimum or in many cases eliminated completely once program development is complete.
In modern multi-processing environments, programs often execute in parallel with one or more other programs. In such cases, it is possible that the act of removing trace instructions from a program itself may cause the operation of the program to be adversely affected. Also, an individual trace for each separate program may not be useful as it may be difficult to match the sequence of events in one trace with those in another trace. On the other hand, using a single trace for all programs can also prove difficult as it may restrict programs different in nature to outputting the same type of trace information, and also normal program execution in one program may be held up as it tries to write trace information while another program locks the trace file.
It is an object of the present invention to provide a method and component for tracing the simultaneous operation of a plurality processes or threads within a single process which mitigates the above problems.
Accordingly, the invention provides a component instantiable to trace the operation of one or more processes in a multi-processing operating system, said component comprising: means for allocating a common buffer within an area of memory; means for writing trace information supplied by a process to said common buffer; said writing means comprising: means for obtaining a next address within said buffer at which to write said trace information and for incrementing said next address to an address in said buffer after said trace information; and means for flushing said buffer if said trace information would exceed the end of said buffer.
In a further aspect the invention provides a method for tracing the operation of one or more processes in a multi-processing operating system, said method comprising the steps of: allocating a common buffer within an area of memory; writing trace information supplied by a process to said common buffer; said writing step comprising: obtaining a next address within said buffer at which to write said trace information and incrementing said next address to an address in said buffer after said trace information; and flushing said buffer if said trace information would exceed the end of said buffer.